#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 1000;
const int M = 1e9 + 7;

int t, xa, ya, xb, yb, xf, yf;

int main()
{
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> t;
    while (t--)
    {
        cin >> xa >> ya >> xb >> yb >> xf >> yf;
        bool flag= false;;

        if (xa == xb && xf == xb)
        {
            if (yf > min(ya, yb) && yf < max(ya, yb))
                flag = true;
        }

        if (ya == yb && yf == yb)
        {
            if (xf > min(xa, xb) && xf < max(xa, xb))
                flag = true;
        }

        int dis = abs(xa - xb) + abs(ya - yb);
        if (flag)
            dis += 2;
        cout << dis << endl;
    }
    return 0;
}